<!--
 * @Author: shenya
 * @Date: 2023-08-11 10:43:16
 * @Description: 任务清单
-->
<template>
  <div>
    <el-dialog
      title="领养任务清单"
      :visible.sync="visible"
      width="1000px"
      append-to-body
    >
      <avue-crud
        ref="crud"
        v-model="form"
        :page.sync="page"
        :data="tableData"
        :table-loading="tableLoading"
        :option="listOption"
        @on-load="getList"
        @search-change="searchChange"
        @search-reset="searchReset"
      >
        <template
          slot="menu"
          slot-scope="scope"
        >
          <el-button
            type="text"
            size="small"
            icon="el-icon-edit"
            @click="review(scope.row)"
          >查看任务反馈
          </el-button>
        </template>
      </avue-crud>
    </el-dialog>
    <task-detail-dialog
      v-if="taskVisible"
      v-model="taskVisible"
      :task-obj="taskObj"
    ></task-detail-dialog>
  </div>
</template>
<script>
import crudMixins from '@/mixins/crud';
import { selectTaskList } from '@/api/core/feedback';
import { listOption } from '@/const/crud/follow/feedback';
import taskDetailDialog from './taskDetailDialog.vue';
export default {
  components: { taskDetailDialog },
  mixins: [crudMixins],
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    id: {
      type: String,
    },
  },
  data() {
    return {
      form: {},
      listOption: listOption(),
      tableLoading: false,
      taskVisible: false,
      taskObj: {},
    };
  },
  computed: {
    visible: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit('input', val);
      },
    },
  },
  methods: {
    //查看任务反馈
    review(row) {
      this.taskObj = row;
      this.taskVisible = true;
    },
    // 列表查询
    getList(page, refresh) {
      if (refresh) {
        this.page.current = 1;
        this.page.currentPage = 1;
      }
      this.tableLoading = true;
      selectTaskList(
        Object.assign(
          {
            relatedId: this.id,
            current: this.page.currentPage,
            size: this.page.pageSize,
          },
          this.searchForm
        )
      )
        .then((response) => {
          this.tableData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>
